# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=flac
pkgver=1.3.4
pkgrel=0
pkgdesc="Free Lossless Audio Codec"
url="https://xiph.org/flac/"
arch="all"
license="custom:Xiph LGPL GPL FDL"
options="!check" # Tests are infinite
subpackages="$pkgname-dev $pkgname-doc"
makedepends="libogg-dev !libiconv"
source="http://downloads.xiph.org/releases/flac/flac-$pkgver.tar.xz"

# secfixes:
#   1.3.4-r0:
#     - CVE-2020-0499
#     - CVE-2021-0561
#   1.3.2-r2:
#     - CVE-2017-6888


build() {
	local _arch_conf
	case "$CARCH" in
		ppc*)	_arch_conf="--enable-altivec" ;;
		x86_64)	_arch_conf="--enable-sse" ;;
		x86)	_arch_conf="--disable-sse" ;;
	esac

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--enable-shared \
		--enable-ogg \
		--disable-rpath \
		--with-pic \
		$_arch_conf
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm0644 COPYING.Xiph \
		"$pkgdir"/usr/share/licenses/$pkgname/COPYING.Xiph
}
sha512sums="
4a626e8a1bd126e234c0e5061e3b46f3a27c2065fdfa228fd8cf00d3c7fa2c05fafb5cec36acce7bfce4914bfd7db0b2a27ee15decf2d8c4caad630f62d44ec9  flac-1.3.4.tar.xz
"
